Page({
  data: {
    page: 0,
    store_list: [],
  },
  onLoad() {
    var app = getApp();
    var url = app.globadData.apiUrlHeader + 'get-stores-list';
    my.httpRequest({
      url: url, // 目标服务器 url
      method: 'POST',
      headers: {'Content-Type': 'Application/json'},
      data: JSON.stringify({'access_token': app.globadData.access_token, page: this.page}),
      success: (res) => {
        if (res.data.message == 'success') {
          this.setData({store_list: res.data.data});
        }
      },
    });
  },
  loadMore() {
    var app = getApp();
    var url = app.globadData.apiUrlHeader + 'get-stores-list';
    var page_n = this.page + 1;
    my.httpRequest({
      url: url, // 目标服务器 url
      method: 'POST',
      headers: {'Content-Type': 'Application/json'},
      data: JSON.stringify({'access_token': app.globadData.access_token, page: page_n}),
      success: (res) => {
        if (res.data.message == 'success' && res.data.data) {
          store_list.concat(res.data.data);
          this.setData({store_list: res.data.data, page: page_n});
        }
      },
    });
  },
  redirectStoreIndex(e) {
    my.redirectTo({
      url: '/pages/main/store-index/store-index?query=' + e.target.dataset.id,
    });
  }
});
